home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / ImageCodec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-22  |  14.2 KB  |  392 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ImageCodec.h
  3.  
  4.      Contains:    QuickTime interfaces
  5.  
  6.      Version:    Technology:    Technology:    QuickTime 2.5
  7.                  Package:    Universal Interfaces 2.1.4
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __IMAGECODEC__
  19. #define __IMAGECODEC__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __QUICKDRAW__
  25. #include <Quickdraw.h>
  26. #endif
  27. #ifndef __QDOFFSCREEN__
  28. #include <QDOffscreen.h>
  29. #endif
  30. #ifndef __WINDOWS__
  31. #include <Windows.h>
  32. #endif
  33. #ifndef __IMAGECOMPRESSION__
  34. #include <ImageCompression.h>
  35. #endif
  36. #ifndef __COMPONENTS__
  37. #include <Components.h>
  38. #endif
  39. #ifndef __MOVIES__
  40. #include <Movies.h>
  41. #endif
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT_SUPPORTED
  48. #pragma import on
  49. #endif
  50.  
  51. #if PRAGMA_ALIGN_SUPPORTED
  52. #pragma options align=mac68k
  53. #endif
  54.  
  55. /*    codec capabilities flags    */
  56.  
  57. enum {
  58.     codecCanScale                = 1L << 0,
  59.     codecCanMask                = 1L << 1,
  60.     codecCanMatte                = 1L << 2,
  61.     codecCanTransform            = 1L << 3,
  62.     codecCanTransferMode        = 1L << 4,
  63.     codecCanCopyPrev            = 1L << 5,
  64.     codecCanSpool                = 1L << 6,
  65.     codecCanClipVertical        = 1L << 7,
  66.     codecCanClipRectangular        = 1L << 8,
  67.     codecCanRemapColor            = 1L << 9,
  68.     codecCanFastDither            = 1L << 10,
  69.     codecCanSrcExtract            = 1L << 11,
  70.     codecCanCopyPrevComp        = 1L << 12,
  71.     codecCanAsync                = 1L << 13,
  72.     codecCanMakeMask            = 1L << 14,
  73.     codecCanShift                = 1L << 15,
  74.     codecCanAsyncWhen            = 1L << 16,
  75.     codecCanShieldCursor        = 1L << 17,
  76.     codecCanManagePrevBuffer    = 1L << 18,
  77.     codecHasVolatileBuffer        = 1L << 19,
  78.     codecWantsRegionMask        = 1L << 20,
  79.     codecImageBufferIsOnScreen    = 1L << 21,
  80.     codecWantsDestinationPixels    = 1L << 22
  81. };
  82.  
  83. struct CodecCapabilities {
  84.     long                             flags;
  85.     short                             wantedPixelSize;
  86.     short                             extendWidth;
  87.     short                             extendHeight;
  88.     short                             bandMin;
  89.     short                             bandInc;
  90.     short                             pad;
  91.     unsigned long                     time;
  92. };
  93. typedef struct CodecCapabilities CodecCapabilities;
  94.  
  95. /*    codec condition flags    */
  96.  
  97. enum {
  98.     codecConditionFirstBand        = 1L << 0,
  99.     codecConditionLastBand        = 1L << 1,
  100.     codecConditionFirstFrame    = 1L << 2,
  101.     codecConditionNewDepth        = 1L << 3,
  102.     codecConditionNewTransform    = 1L << 4,
  103.     codecConditionNewSrcRect    = 1L << 5,
  104.     codecConditionNewMask        = 1L << 6,
  105.     codecConditionNewMatte        = 1L << 7,
  106.     codecConditionNewTransferMode = 1L << 8,
  107.     codecConditionNewClut        = 1L << 9,
  108.     codecConditionNewAccuracy    = 1L << 10,
  109.     codecConditionNewDestination = 1L << 11,
  110.     codecConditionFirstScreen    = 1L << 12,
  111.     codecConditionDoCursor        = 1L << 13,
  112.     codecConditionCatchUpDiff    = 1L << 14,
  113.     codecConditionMaskMayBeChanged = 1L << 15,
  114.     codecConditionToBuffer        = 1L << 16,
  115.     codecConditionCodecChangedMask = 1L << 31
  116. };
  117.  
  118.  
  119. enum {
  120.     codecInfoResourceType        = 'cdci',                        /* codec info resource type */
  121.     codecInterfaceVersion        = 2                                /* high word returned in component GetVersion */
  122. };
  123.  
  124. struct CDSequenceDataSource {
  125.     long                             recordSize;
  126.  
  127.     void *                            next;
  128.  
  129.     ImageSequence                     seqID;
  130.     ImageSequenceDataSource         sourceID;
  131.     OSType                             sourceType;
  132.     long                             sourceInputNumber;
  133.     void *                            dataPtr;
  134.     Handle                             dataDescription;
  135.     long                             changeSeed;
  136.     ICMConvertDataFormatUPP         transferProc;
  137.     void *                            transferRefcon;
  138.                                                                 /* The following fields only exist for QuickTime 2.5 and greater */
  139.     long                             dataSize;
  140. };
  141. typedef struct CDSequenceDataSource CDSequenceDataSource;
  142.  
  143. typedef CDSequenceDataSource *CDSequenceDataSourcePtr;
  144. struct CodecCompressParams {
  145.     ImageSequence                     sequenceID;                    /* precompress,bandcompress */
  146.     ImageDescriptionHandle             imageDescription;            /* precompress,bandcompress */
  147.     Ptr                             data;
  148.     long                             bufferSize;
  149.     long                             frameNumber;
  150.     long                             startLine;
  151.     long                             stopLine;
  152.     long                             conditionFlags;
  153.     CodecFlags                         callerFlags;
  154.     CodecCapabilities *                capabilities;                /* precompress,bandcompress */
  155.     ICMProgressProcRecord             progressProcRecord;
  156.     ICMCompletionProcRecord         completionProcRecord;
  157.     ICMFlushProcRecord                 flushProcRecord;
  158.  
  159.     PixMap                             srcPixMap;                    /* precompress,bandcompress */
  160.     PixMap                             prevPixMap;
  161.     CodecQ                             spatialQuality;
  162.     CodecQ                             temporalQuality;
  163.     Fixed                             similarity;
  164.     DataRateParamsPtr                 dataRateParams;
  165.     long                             reserved;
  166.  
  167.                                                                 /* The following fields only exist for QuickTime 2.1 and greater */
  168.     UInt16                             majorSourceChangeSeed;
  169.     UInt16                             minorSourceChangeSeed;
  170.     CDSequenceDataSourcePtr         sourceData;
  171.  
  172.                                                                 /* The following fields only exit for QuickTime 2.5 and greater */
  173.     long                             preferredPacketSizeInBytes;
  174. };
  175. typedef struct CodecCompressParams CodecCompressParams;
  176.  
  177. struct CodecDecompressParams {
  178.     ImageSequence                     sequenceID;                    /* predecompress,banddecompress */
  179.     ImageDescriptionHandle             imageDescription;            /* predecompress,banddecompress */
  180.     Ptr                             data;
  181.     long                             bufferSize;
  182.     long                             frameNumber;
  183.     long                             startLine;
  184.     long                             stopLine;
  185.     long                             conditionFlags;
  186.     CodecFlags                         callerFlags;
  187.     CodecCapabilities *                capabilities;                /* predecompress,banddecompress */
  188.     ICMProgressProcRecord             progressProcRecord;
  189.     ICMCompletionProcRecord         completionProcRecord;
  190.     ICMDataProcRecord                 dataProcRecord;
  191.  
  192.     CGrafPtr                         port;                        /* predecompress,banddecompress */
  193.     PixMap                             dstPixMap;                    /* predecompress,banddecompress */
  194.     BitMapPtr                         maskBits;
  195.     PixMapPtr                         mattePixMap;
  196.     Rect                             srcRect;                    /* predecompress,banddecompress */
  197.     MatrixRecord *                    matrix;                        /* predecompress,banddecompress */
  198.     CodecQ                             accuracy;                    /* predecompress,banddecompress */
  199.     short                             transferMode;                /* predecompress,banddecompress */
  200.     ICMFrameTimePtr                 frameTime;                    /* banddecompress */
  201.     long                             reserved[1];
  202.                                                                 /* The following fields only exist for QuickTime 2.0 and greater */
  203.     SInt8                             matrixFlags;                /* high bit set if 2x resize */
  204.     SInt8                             matrixType;
  205.     Rect                             dstRect;                    /* only valid for simple transforms */
  206.                                                                 /* The following fields only exist for QuickTime 2.1 and greater */
  207.     UInt16                             majorSourceChangeSeed;
  208.     UInt16                             minorSourceChangeSeed;
  209.     CDSequenceDataSourcePtr         sourceData;
  210.  
  211.     RgnHandle                         maskRegion;
  212.  
  213.                                                                 /* The following fields only exist for QuickTime 2.5 and greater */
  214.  
  215.     OSType **                        wantedDestinationPixelTypes; /* Handle to 0-terminated list of OSTypes */
  216.  
  217.     long                             screenFloodMethod;
  218.     long                             screenFloodValue;
  219.     short                             preferredOffscreenPixelSize;
  220. };
  221. typedef struct CodecDecompressParams CodecDecompressParams;
  222.  
  223.  
  224. enum {
  225.     matrixFlagScale2x            = 1L << 7,
  226.     matrixFlagScale1x            = 1L << 6,
  227.     matrixFlagScaleHalf            = 1L << 5
  228. };
  229.  
  230.  
  231. enum {
  232.     kScreenFloodMethodNone        = 0,
  233.     kScreenFloodMethodKeyColor    = 1,
  234.     kScreenFloodMethodAlpha        = 2
  235. };
  236.  
  237. /*    codec selectors 0-127 are reserved by Apple */
  238. /*    codec selectors 128-191 are subtype specific */
  239. /*    codec selectors 192-255 are vendor specific */
  240. /*    codec selectors 256-32767 are available for general use */
  241. /*    negative selectors are reserved by the Component Manager */
  242. extern pascal ComponentResult ImageCodecGetCodecInfo(ComponentInstance ci, CodecInfo *info)
  243.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0000, 0x7000, 0xA82A);
  244.  
  245. extern pascal ComponentResult ImageCodecGetCompressionTime(ComponentInstance ci, PixMapHandle src, const Rect *srcRect, short depth, CodecQ *spatialQuality, CodecQ *temporalQuality, unsigned long *time)
  246.  FIVEWORDINLINE(0x2F3C, 0x0016, 0x0001, 0x7000, 0xA82A);
  247.  
  248. extern pascal ComponentResult ImageCodecGetMaxCompressionSize(ComponentInstance ci, PixMapHandle src, const Rect *srcRect, short depth, CodecQ quality, long *size)
  249.  FIVEWORDINLINE(0x2F3C, 0x0012, 0x0002, 0x7000, 0xA82A);
  250.  
  251. extern pascal ComponentResult ImageCodecPreCompress(ComponentInstance ci, CodecCompressParams *params)
  252.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0003, 0x7000, 0xA82A);
  253.  
  254. extern pascal ComponentResult ImageCodecBandCompress(ComponentInstance ci, CodecCompressParams *params)
  255.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0004, 0x7000, 0xA82A);
  256.  
  257. extern pascal ComponentResult ImageCodecPreDecompress(ComponentInstance ci, CodecDecompressParams *params)
  258.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0005, 0x7000, 0xA82A);
  259.  
  260. extern pascal ComponentResult ImageCodecBandDecompress(ComponentInstance ci, CodecDecompressParams *params)
  261.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0006, 0x7000, 0xA82A);
  262.  
  263. extern pascal ComponentResult ImageCodecBusy(ComponentInstance ci, ImageSequence seq)
  264.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0007, 0x7000, 0xA82A);
  265.  
  266. extern pascal ComponentResult ImageCodecGetCompressedImageSize(ComponentInstance ci, ImageDescriptionHandle desc, Ptr data, long bufferSize, ICMDataProcRecordPtr dataProc, long *dataSize)
  267.  FIVEWORDINLINE(0x2F3C, 0x0014, 0x0008, 0x7000, 0xA82A);
  268.  
  269. extern pascal ComponentResult ImageCodecGetSimilarity(ComponentInstance ci, PixMapHandle src, const Rect *srcRect, ImageDescriptionHandle desc, Ptr data, Fixed *similarity)
  270.  FIVEWORDINLINE(0x2F3C, 0x0014, 0x0009, 0x7000, 0xA82A);
  271.  
  272. extern pascal ComponentResult ImageCodecTrimImage(ComponentInstance ci, ImageDescriptionHandle Desc, Ptr inData, long inBufferSize, ICMDataProcRecordPtr dataProc, Ptr outData, long outBufferSize, ICMFlushProcRecordPtr flushProc, Rect *trimRect, ICMProgressProcRecordPtr progressProc)
  273.  FIVEWORDINLINE(0x2F3C, 0x0024, 0x000A, 0x7000, 0xA82A);
  274.  
  275. extern pascal ComponentResult ImageCodecRequestSettings(ComponentInstance ci, Handle settings, Rect *rp, ModalFilterUPP filterProc)
  276.  FIVEWORDINLINE(0x2F3C, 0x000C, 0x000B, 0x7000, 0xA82A);
  277.  
  278. extern pascal ComponentResult ImageCodecGetSettings(ComponentInstance ci, Handle settings)
  279.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x000C, 0x7000, 0xA82A);
  280.  
  281. extern pascal ComponentResult ImageCodecSetSettings(ComponentInstance ci, Handle settings)
  282.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x000D, 0x7000, 0xA82A);
  283.  
  284. extern pascal ComponentResult ImageCodecFlush(ComponentInstance ci)
  285.  FIVEWORDINLINE(0x2F3C, 0x0000, 0x000E, 0x7000, 0xA82A);
  286.  
  287. extern pascal ComponentResult ImageCodecSetTimeCode(ComponentInstance ci, void *timeCodeFormat, void *timeCodeTime)
  288.  FIVEWORDINLINE(0x2F3C, 0x0008, 0x000F, 0x7000, 0xA82A);
  289.  
  290. extern pascal ComponentResult ImageCodecIsImageDescriptionEquivalent(ComponentInstance ci, ImageDescriptionHandle newDesc, Boolean *equivalent)
  291.  FIVEWORDINLINE(0x2F3C, 0x0008, 0x0010, 0x7000, 0xA82A);
  292.  
  293. extern pascal ComponentResult ImageCodecNewMemory(ComponentInstance ci, Ptr *data, Size dataSize, long dataUse, ICMMemoryDisposedUPP memoryGoneProc, void *refCon)
  294.  FIVEWORDINLINE(0x2F3C, 0x0014, 0x0011, 0x7000, 0xA82A);
  295.  
  296. extern pascal ComponentResult ImageCodecDisposeMemory(ComponentInstance ci, Ptr data)
  297.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0012, 0x7000, 0xA82A);
  298.  
  299. extern pascal ComponentResult ImageCodecHitTestData(ComponentInstance ci, ImageDescriptionHandle desc, void *data, Size dataSize, Point where, Boolean *hit)
  300.  FIVEWORDINLINE(0x2F3C, 0x0014, 0x0013, 0x7000, 0xA82A);
  301.  
  302. extern pascal ComponentResult ImageCodecNewImageBufferMemory(ComponentInstance ci, CodecDecompressParams *params, long flags, ICMMemoryDisposedUPP memoryGoneProc, void *refCon)
  303.  FIVEWORDINLINE(0x2F3C, 0x0010, 0x0014, 0x7000, 0xA82A);
  304.  
  305. extern pascal ComponentResult ImageCodecExtractAndCombineFields(ComponentInstance ci, long fieldFlags, void *data1, long dataSize1, ImageDescriptionHandle desc1, void *data2, long dataSize2, ImageDescriptionHandle desc2, void *outputData, long *outDataSize, ImageDescriptionHandle descOut)
  306.  FIVEWORDINLINE(0x2F3C, 0x0028, 0x0015, 0x7000, 0xA82A);
  307.  
  308. extern pascal ComponentResult ImageCodecGetMaxCompressionSizeWithSources(ComponentInstance ci, PixMapHandle src, const Rect *srcRect, short depth, CodecQ quality, CDSequenceDataSourcePtr sourceData, long *size)
  309.  FIVEWORDINLINE(0x2F3C, 0x0016, 0x0016, 0x7000, 0xA82A);
  310.  
  311.  
  312. /* selectors for component calls */
  313. enum {
  314.     kImageCodecGetCodecInfoSelect                    = 0x0000,
  315.     kImageCodecGetCompressionTimeSelect                = 0x0001,
  316.     kImageCodecGetMaxCompressionSizeSelect            = 0x0002,
  317.     kImageCodecPreCompressSelect                    = 0x0003,
  318.     kImageCodecBandCompressSelect                    = 0x0004,
  319.     kImageCodecPreDecompressSelect                    = 0x0005,
  320.     kImageCodecBandDecompressSelect                    = 0x0006,
  321.     kImageCodecBusySelect                            = 0x0007,
  322.     kImageCodecGetCompressedImageSizeSelect            = 0x0008,
  323.     kImageCodecGetSimilaritySelect                    = 0x0009,
  324.     kImageCodecTrimImageSelect                        = 0x000A,
  325.     kImageCodecRequestSettingsSelect                = 0x000B,
  326.     kImageCodecGetSettingsSelect                    = 0x000C,
  327.     kImageCodecSetSettingsSelect                    = 0x000D,
  328.     kImageCodecFlushSelect                            = 0x000E,
  329.     kImageCodecSetTimeCodeSelect                    = 0x000F,
  330.     kImageCodecIsImageDescriptionEquivalentSelect    = 0x0010,
  331.     kImageCodecNewMemorySelect                        = 0x0011,
  332.     kImageCodecDisposeMemorySelect                    = 0x0012,
  333.     kImageCodecHitTestDataSelect                    = 0x0013,
  334.     kImageCodecNewImageBufferMemorySelect            = 0x0014,
  335.     kImageCodecExtractAndCombineFieldsSelect        = 0x0015,
  336.     kImageCodecGetMaxCompressionSizeWithSourcesSelect = 0x0016
  337. };
  338.  
  339. enum {
  340.     kMotionJPEGTag                = 'mjpg'
  341. };
  342.  
  343. struct MotionJPEGApp1Marker {
  344.     long                             unused;
  345.     long                             tag;
  346.     long                             fieldSize;
  347.     long                             paddedFieldSize;
  348.     long                             offsetToNextField;
  349.     long                             qTableOffset;
  350.     long                             huffmanTableOffset;
  351.     long                             sofOffset;
  352.     long                             sosOffset;
  353.     long                             soiOffset;
  354. };
  355. typedef struct MotionJPEGApp1Marker MotionJPEGApp1Marker;
  356.  
  357. extern pascal ComponentResult QTPhotoSetSampling(ComponentInstance codec, short yH, short yV, short cbH, short cbV, short crH, short crV)
  358.  FIVEWORDINLINE(0x2F3C, 0x000C, 0x0100, 0x7000, 0xA82A);
  359.  
  360. extern pascal ComponentResult QTPhotoSetRestartInterval(ComponentInstance codec, unsigned short restartInterval)
  361.  FIVEWORDINLINE(0x2F3C, 0x0002, 0x0101, 0x7000, 0xA82A);
  362.  
  363. extern pascal ComponentResult QTPhotoDefineHuffmanTable(ComponentInstance codec, short componentNumber, Boolean isDC, unsigned char *lengthCounts, unsigned char *values)
  364.  FIVEWORDINLINE(0x2F3C, 0x000C, 0x0102, 0x7000, 0xA82A);
  365.  
  366. extern pascal ComponentResult QTPhotoDefineQuantizationTable(ComponentInstance codec, short componentNumber, unsigned char *table)
  367.  FIVEWORDINLINE(0x2F3C, 0x0006, 0x0103, 0x7000, 0xA82A);
  368.  
  369.  
  370. /* selectors for component calls */
  371. enum {
  372.     kQTPhotoSetSamplingSelect                        = 0x0100,
  373.     kQTPhotoSetRestartIntervalSelect                = 0x0101,
  374.     kQTPhotoDefineHuffmanTableSelect                = 0x0102,
  375.     kQTPhotoDefineQuantizationTableSelect            = 0x0103
  376. };
  377.  
  378. #if PRAGMA_ALIGN_SUPPORTED
  379. #pragma options align=reset
  380. #endif
  381.  
  382. #if PRAGMA_IMPORT_SUPPORTED
  383. #pragma import off
  384. #endif
  385.  
  386. #ifdef __cplusplus
  387. }
  388. #endif
  389.  
  390. #endif /* __IMAGECODEC__ */
  391.  
  392.